Skip to main content

All Questions

2votes
3answers
199views

Is it still "feature envy" if the state to make decision or the action to take after asking the state involves other classes to participate?

According to https://softwareengineering.stackexchange.com/a/212130/432039, if a class asks another class for the state, and then call methods of that class, it is called "feature envy", eg: ...
wcminipgasker2023's user avatar
106votes
11answers
26kviews

Is putting general-use functions in a "helpers" file an anti-pattern or code smell?

Is it an anti-pattern or code smell to put "general use" functions (examples below) into a catch-all file named "helpers" or "utils"? It's a pattern I've seen quite a lot ...
old greg's user avatar
0votes
1answer
141views

Is a "concrete function" over "generic function" a good implementation?

I want to know others opinion about this approach that I use in a lot of projects, for example, I can show the last time that I use it: public class DataStorageService { private enum Keys { ...
Tlaloc-ES's user avatar
0votes
1answer
564views

use always get and set methods is a bad practique, is call directly an attribute class a bad practique in OOP?

I have a doubt about if there are some recommendations for call directly an attribute in a class I think that in OOP you always should call an attribute by the get method. For example: On set ...
Tlaloc-ES's user avatar
10votes
4answers
3kviews

is this way of calling a function a bad practice?

I have the following code: public void moveCameraTo(Location location){ moveCameraTo(location.getLatitude(), location.getLongitude()); } public void moveCameraTo(double latitude, double ...
Tlaloc-ES's user avatar
0votes
5answers
3kviews

Is using the Pair class a sign of primitive obsession code smell?

Let's say I use a Pair in this way: Pair<Long, Date> signup = getSignup(); System.out.println("User with ID " + signup.getLeft() + " signed up on " + signup.getRight()); Is it a form of ...
ddreian's user avatar
3votes
1answer
1kviews

How do I use polymorphism instead of instanceof?

I'm trying to make an abstract board game. In the game, a player can choose to make multiple actions within one turn such as placing, moving, or rotating a piece. I'm not sure if whether or not my ...
Michael Newgate's user avatar
4votes
4answers
1kviews

code smell: passing through variables [closed]

Consider this simple example: def a(val_x, val_y): return 5 + b(val_x, val_y) def b(val_x, val_y): return 1 + c(val_x, val_y) def c(val_x, val_y): return val_x * val_y Passing the ...
Job Evers's user avatar
1vote
1answer
150views

Refactoring code dependent on external class

I have a class similar to ServletFilter which has multiple validation on the input request class TokenHandler implements SomeHandler{ Response handle(Request request){ if(paramXMissing(request))...
sidgate's user avatar
0votes
3answers
2kviews

Does this code have only one level of abstraction?

I'm trying to apply some good practices from Clean Code in my code, but I'm stuck trying to figure out if my code has a [G34] code smell, which tells that functions should descend only one level of ...
kewerson hugo's user avatar
2votes
3answers
440views

Refactoring Atrocious Java Code [duplicate]

So I recently started a new job for a small software company. They've got some old technology which I was aware of during the interview process. However, I've been digging into their code-base, and I'...
A_B's user avatar
  • 409
1vote
2answers
2kviews

How to avoid spaghetti code when I have a lot of conditions? [duplicate]

I have the following problem: An user can withdraw money from 2 payment systems (but the number of payment systems can change anytime in the future). If user has a trusted account on either of these ...
Dmitro's user avatar
10votes
3answers
3kviews

Clean Code and Hybrid Objects and Feature Envy

So I recently made some major refactorings to my code. One of the main things I tried to do was split out my classes into data objects and worker objects. This was inspired, among other things, by ...
durron597's user avatar
75votes
2answers
36kviews

What is a" feature envy" code and why is it considered a code smell?

This question on SO talks about correcting what the OP thought is feature envy code. Another example where I saw this nifty phrase being quoted is in a recently given answer here in programmers.SE. ...
Geek's user avatar
  • 5,217
6votes
6answers
403views

Is code maintenance typically a special project, or is it considered part of daily work?

Earlier, I asked to find out which tools are commonly used to monitor methods and code bases, to find out whether the methods have been getting too long. Most of the responses there suggested that, ...
blueberryfields's user avatar

close